/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Forms;

import BLL.BLLNhanVien;
import DTO.DTONhanVien;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Documents
 */
public class DanhSachNhanVien extends javax.swing.JFrame {
    BLLNhanVien bllNV = new BLLNhanVien();
    DefaultTableModel modelNV;
    /**
     * Creates new form NhanSu
     */
    public DanhSachNhanVien() {
        initComponents();
        modelNV = new DefaultTableModel();
        String muc[] = {"Mã số", "Họ tên", "Ngày sinh", "Giới tính"};
        modelNV.setColumnIdentifiers(muc);
        jTableDSNV.setModel(modelNV);
        LayDLVaoBang();
    }
    
    private void LayDLVaoBang(){
         try {
            for(DTONhanVien dtoNV : bllNV.LayToanBoNhanVien()){
                modelNV.addRow(new Object[]{dtoNV.getMaNV(), dtoNV.getHoTen(), 
                    dtoNV.getNgaySinh(), dtoNV.getGioiTinh()});
            }
        } catch (Exception e) {
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        jpnlChiTiet = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jtxtMaNV = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jtxtHoTen = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jtxtNgaySinh = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jtxtDiaChi = new javax.swing.JTextField();
        jtxtCmnd = new javax.swing.JTextField();
        jrabtnBacSi = new javax.swing.JRadioButton();
        jrabtnYTa = new javax.swing.JRadioButton();
        jtxtChuyenKhoa = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jrabtnNam = new javax.swing.JRadioButton();
        jrabtnNu = new javax.swing.JRadioButton();
        jLabel10 = new javax.swing.JLabel();
        jtxtDienThoai = new javax.swing.JTextField();
        jtxtChucVu = new javax.swing.JTextField();
        jpnlTuyChon = new javax.swing.JPanel();
        jbtnThem = new javax.swing.JButton();
        jbtnSua = new javax.swing.JButton();
        jbtnXoa = new javax.swing.JButton();
        jpnlTim = new javax.swing.JPanel();
        jtxtTim = new javax.swing.JTextField();
        jbtnTim = new javax.swing.JButton();
        btnReload = new javax.swing.JButton();
        jpnlDanhSach = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTableDSNV = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setResizable(false);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(0, 102, 0));
        jLabel1.setText("DANH SÁCH NHÂN VIÊN");

        jpnlChiTiet.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(255, 255, 255), new java.awt.Color(0, 0, 102)), "Thông tin chi tiết"));

        jLabel2.setText("Mã nhân viên");

        jtxtMaNV.setEnabled(false);

        jLabel3.setText("Họ tên");

        jtxtHoTen.setEnabled(false);
        jtxtHoTen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtHoTenActionPerformed(evt);
            }
        });

        jLabel4.setText("Giới tính");

        jLabel5.setText("Ngày sinh");

        jLabel6.setText("CMND");

        jtxtNgaySinh.setEnabled(false);

        jLabel7.setText("Địa chỉ");

        jtxtDiaChi.setEnabled(false);

        jtxtCmnd.setEnabled(false);

        buttonGroup2.add(jrabtnBacSi);
        jrabtnBacSi.setText("Bác sĩ");
        jrabtnBacSi.setEnabled(false);

        buttonGroup2.add(jrabtnYTa);
        jrabtnYTa.setText("Y tá");
        jrabtnYTa.setEnabled(false);
        jrabtnYTa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jrabtnYTaActionPerformed(evt);
            }
        });

        jtxtChuyenKhoa.setEnabled(false);

        jLabel11.setText("Chuyên khoa");

        jLabel12.setText("Chức vụ");

        buttonGroup1.add(jrabtnNam);
        jrabtnNam.setText("Nam");
        jrabtnNam.setEnabled(false);

        buttonGroup1.add(jrabtnNu);
        jrabtnNu.setText("Nữ");
        jrabtnNu.setEnabled(false);

        jLabel10.setText("Điện thoại");

        jtxtDienThoai.setEnabled(false);

        jtxtChucVu.setEnabled(false);

        javax.swing.GroupLayout jpnlChiTietLayout = new javax.swing.GroupLayout(jpnlChiTiet);
        jpnlChiTiet.setLayout(jpnlChiTietLayout);
        jpnlChiTietLayout.setHorizontalGroup(
            jpnlChiTietLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnlChiTietLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpnlChiTietLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jpnlChiTietLayout.createSequentialGroup()
                        .addGroup(jpnlChiTietLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addComponent(jLabel7)
                            .addComponent(jLabel2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jpnlChiTietLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jpnlChiTietLayout.createSequentialGroup()
                                .addGroup(jpnlChiTietLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jtxtNgaySinh, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jtxtMaNV, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addGroup(jpnlChiTietLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel6)
                                    .addComponent(jLabel3))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jpnlChiTietLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(jpnlChiTietLayout.createSequentialGroup()
                                        .addComponent(jtxtCmnd, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jLabel10))
                                    .addComponent(jtxtHoTen, javax.swing.GroupLayout.PREFERRED_SIZE, 203, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jpnlChiTietLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(jpnlChiTietLayout.createSequentialGroup()
                                        .addGap(23, 23, 23)
                                        .addComponent(jtxtDienThoai, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jpnlChiTietLayout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jrabtnNam, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jrabtnNu, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addComponent(jtxtDiaChi)))
                    .addGroup(jpnlChiTietLayout.createSequentialGroup()
                        .addComponent(jrabtnBacSi)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jrabtnYTa)
                        .addGap(37, 37, 37)
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jtxtChuyenKhoa, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jtxtChucVu)))
                .addContainerGap(53, Short.MAX_VALUE))
        );
        jpnlChiTietLayout.setVerticalGroup(
            jpnlChiTietLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnlChiTietLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpnlChiTietLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jpnlChiTietLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel3)
                        .addComponent(jtxtHoTen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jtxtMaNV, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jrabtnNam)
                        .addComponent(jLabel4)
                        .addComponent(jrabtnNu)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jpnlChiTietLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6)
                    .addComponent(jtxtNgaySinh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtxtCmnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(jtxtDienThoai, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jpnlChiTietLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jtxtDiaChi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jpnlChiTietLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jrabtnBacSi)
                    .addComponent(jrabtnYTa)
                    .addComponent(jtxtChuyenKhoa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11)
                    .addComponent(jLabel12)
                    .addComponent(jtxtChucVu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jpnlTuyChon.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(0, 0, 102)), "Tùy chọn"));

        jbtnThem.setText("Thêm mới");
        jbtnThem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnThemActionPerformed(evt);
            }
        });

        jbtnSua.setText("Sửa");
        jbtnSua.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnSuaActionPerformed(evt);
            }
        });

        jbtnXoa.setText("Xóa");
        jbtnXoa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnXoaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jpnlTuyChonLayout = new javax.swing.GroupLayout(jpnlTuyChon);
        jpnlTuyChon.setLayout(jpnlTuyChonLayout);
        jpnlTuyChonLayout.setHorizontalGroup(
            jpnlTuyChonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnlTuyChonLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpnlTuyChonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jbtnThem, javax.swing.GroupLayout.DEFAULT_SIZE, 87, Short.MAX_VALUE)
                    .addComponent(jbtnSua, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jbtnXoa, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jpnlTuyChonLayout.setVerticalGroup(
            jpnlTuyChonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnlTuyChonLayout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(jbtnThem, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jbtnSua, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jbtnXoa, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jpnlTim.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(0, 0, 102)), "Tìm kiếm"));

        jbtnTim.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icons/IconsLandVista.png"))); // NOI18N
        jbtnTim.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnTimActionPerformed(evt);
            }
        });

        btnReload.setText("Tải lại");
        btnReload.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnReloadActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jpnlTimLayout = new javax.swing.GroupLayout(jpnlTim);
        jpnlTim.setLayout(jpnlTimLayout);
        jpnlTimLayout.setHorizontalGroup(
            jpnlTimLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpnlTimLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jbtnTim, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtxtTim, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnReload)
                .addContainerGap())
        );
        jpnlTimLayout.setVerticalGroup(
            jpnlTimLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnlTimLayout.createSequentialGroup()
                .addGroup(jpnlTimLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jpnlTimLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jtxtTim, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(btnReload))
                    .addComponent(jbtnTim))
                .addGap(0, 3, Short.MAX_VALUE))
        );

        jpnlDanhSach.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(0, 0, 102)), "Danh sách nhân viên"));

        jTableDSNV.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jTableDSNV.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTableDSNVMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jTableDSNV);

        javax.swing.GroupLayout jpnlDanhSachLayout = new javax.swing.GroupLayout(jpnlDanhSach);
        jpnlDanhSach.setLayout(jpnlDanhSachLayout);
        jpnlDanhSachLayout.setHorizontalGroup(
            jpnlDanhSachLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1)
        );
        jpnlDanhSachLayout.setVerticalGroup(
            jpnlDanhSachLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpnlDanhSachLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 259, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(90, 90, 90))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(262, 262, 262)
                .addComponent(jLabel1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addComponent(jpnlChiTiet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jpnlTuyChon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
            .addComponent(jpnlTim, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jpnlDanhSach, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jpnlTuyChon, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jpnlChiTiet, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jpnlTim, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jpnlDanhSach, javax.swing.GroupLayout.PREFERRED_SIZE, 303, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jtxtHoTenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtHoTenActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jtxtHoTenActionPerformed

    private void jrabtnYTaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrabtnYTaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jrabtnYTaActionPerformed

    private void jTableDSNVMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableDSNVMouseClicked
         try {
            int maNhanVien = Integer.valueOf(jTableDSNV.getValueAt(jTableDSNV.getSelectedRow(), 0).toString());
            DTONhanVien dtoNhanVien= bllNV.layNhanVienTheoMa(maNhanVien);
            if(dtoNhanVien != null){
                jtxtMaNV.setText(String.valueOf(dtoNhanVien.getMaNV()));
                jtxtHoTen.setText(dtoNhanVien.getHoTen());
                //gioi tinh
                if("Nam".equals(dtoNhanVien.getGioiTinh()))
                    jrabtnNam.setSelected(true);
                else
                    jrabtnNu.setSelected(true);
                
                jtxtNgaySinh.setText(String.valueOf(dtoNhanVien.getNgaySinh()));
                jtxtCmnd.setText(dtoNhanVien.getCmnd());
                jtxtDienThoai.setText(dtoNhanVien.getDienThoai());
                jtxtDiaChi.setText(dtoNhanVien.getDiaChi());
                //hoc vi
                if("Bác sĩ".equals(dtoNhanVien.getHocVi()))
                    jrabtnBacSi.setSelected(true);
                else
                    jrabtnYTa.setSelected(true);
                jtxtChuyenKhoa.setText(dtoNhanVien.getDtoCK().getTenChuyenKhoa());
                jtxtChucVu.setText(dtoNhanVien.getDtoCV().getTenChucVu());
            }
            else
                JOptionPane.showMessageDialog(null, "Không có nhân viên này");
        } catch (Exception e) {
        }
    }//GEN-LAST:event_jTableDSNVMouseClicked

    private void jbtnSuaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnSuaActionPerformed
        try{
            int maNV = -1;
            maNV = Integer.valueOf(jTableDSNV.getValueAt(jTableDSNV.getSelectedRow(), 0).toString());
            if(maNV != -1)
            {
                SuaThongTinNhanVien nv = new SuaThongTinNhanVien(maNV);
                Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
                nv.setLocation((dim.width - nv.getWidth())/2, (dim.height - nv.getHeight())/2);
                nv.setVisible(true);
            }
        }catch(Exception e){
            JOptionPane.showMessageDialog(null, "Vui lòng chọn nhân viên cần sửa");
        }
        
    }//GEN-LAST:event_jbtnSuaActionPerformed

    private void jbtnThemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnThemActionPerformed
        ThemNhanVien nv = new ThemNhanVien();
        Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
        nv.setLocation((dim.width - nv.getWidth())/2, (dim.height - nv.getHeight())/2);
        nv.setVisible(true);
    }//GEN-LAST:event_jbtnThemActionPerformed

    private void btnReloadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnReloadActionPerformed
        for(int i = jTableDSNV.getRowCount() - 1; i>=0 ; i--){
            modelNV.removeRow(i);
        }
        LayDLVaoBang();
    }//GEN-LAST:event_btnReloadActionPerformed

    private void jbtnTimActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnTimActionPerformed
        try{
            if(!"".equals(jtxtTim.getText().trim())){
                String tim = jtxtTim.getText().trim();
                for(int i = jTableDSNV.getRowCount() - 1; i>=0 ; i--){
                    modelNV.removeRow(i);
                }  
                for(DTONhanVien dtoNV : bllNV.timNhanVien(tim)){
                    modelNV.addRow(new Object[]{dtoNV.getMaNV(), dtoNV.getHoTen(), 
                        dtoNV.getNgaySinh(), dtoNV.getGioiTinh()});
                }
            }
            else
                JOptionPane.showMessageDialog(null, "Bạn muốn tìm gì, nhập vào nhé");
        }
        catch(Exception e){
            
        }
    }//GEN-LAST:event_jbtnTimActionPerformed

    private void jbtnXoaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnXoaActionPerformed
        try{
            int[] dong = jTableDSNV.getSelectedRows();
            if(dong.length > 0){
                if(JOptionPane.showConfirmDialog(null, "Bạn có chắc muốn xóa?", "Thông báo", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE)==JOptionPane.YES_OPTION){
                    int dem = 0;
                    for(int i = dong.length - 1; i >= 0; i--){
                        int maNV = Integer.valueOf(jTableDSNV.getValueAt(dong[i], 0).toString());
                        if(bllNV.xoaNhanVien(maNV)){
                            modelNV.removeRow(dong[i]);
                            dem++;
                        }
                        else
                            JOptionPane.showMessageDialog(null, "Không thể xóa");
                    }
                    if(dem==dong.length){
                        JOptionPane.showMessageDialog(null, "Đã xóa nhân viên thành công");
                    }
                }
            }
            else
                JOptionPane.showMessageDialog(null, "Vui lòng chọn mục muốn xóa");
        }
        catch(Exception e){
            JOptionPane.showMessageDialog(null, "Xóa bị lỗi, không thể xóa!");
        }
    }//GEN-LAST:event_jbtnXoaActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(DanhSachNhanVien.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(DanhSachNhanVien.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(DanhSachNhanVien.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(DanhSachNhanVien.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new DanhSachNhanVien().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnReload;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTableDSNV;
    private javax.swing.JButton jbtnSua;
    private javax.swing.JButton jbtnThem;
    private javax.swing.JButton jbtnTim;
    private javax.swing.JButton jbtnXoa;
    private javax.swing.JPanel jpnlChiTiet;
    private javax.swing.JPanel jpnlDanhSach;
    private javax.swing.JPanel jpnlTim;
    private javax.swing.JPanel jpnlTuyChon;
    private javax.swing.JRadioButton jrabtnBacSi;
    private javax.swing.JRadioButton jrabtnNam;
    private javax.swing.JRadioButton jrabtnNu;
    private javax.swing.JRadioButton jrabtnYTa;
    private javax.swing.JTextField jtxtChucVu;
    private javax.swing.JTextField jtxtChuyenKhoa;
    private javax.swing.JTextField jtxtCmnd;
    private javax.swing.JTextField jtxtDiaChi;
    private javax.swing.JTextField jtxtDienThoai;
    private javax.swing.JTextField jtxtHoTen;
    private javax.swing.JTextField jtxtMaNV;
    private javax.swing.JTextField jtxtNgaySinh;
    private javax.swing.JTextField jtxtTim;
    // End of variables declaration//GEN-END:variables
}
